package com.dcy.system.service;

import com.dcy.common.model.PageModel;
import com.dcy.common.base.service.DcyBaseService;
import com.dcy.common.model.PageResult;
import com.dcy.system.dao.LogDao;
import com.dcy.system.vo.in.LogSearchInVO;
import com.dcy.system.vo.out.LogListOutVO;
import com.dcy.system.convert.LogConvert;
import com.dcy.system.model.Log;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 字典表 服务实现类
 * </p>
 *
 * @author dcy
 * @since 2021-01-06
 */
@RequiredArgsConstructor
@Service
public class LogService extends DcyBaseService {

    private final LogDao logDao;
    private final LogConvert logConvert = LogConvert.INSTANCE;

    /**
     * 获取表格数据
     *
     * @param logSearchInVO
     * @param pageModel
     * @return
     */
    public PageResult<LogListOutVO> pageListByEntity(LogSearchInVO logSearchInVO, PageModel pageModel) {
        return toPageResult(logDao.pageListByEntity(logConvert.toLog(logSearchInVO), pageModel), page -> logConvert.toOutputList(page.getRecords()));
    }

    /**
     * 异步调用保存
     *
     * @param log
     */
    @Async
    public void saveLog(Log log) {
        logDao.save(log);
    }
}
